package com.iflytek.springboot_medicine.mapper;

import com.iflytek.springboot_medicine.entity.Apply;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PutMapping;

import java.sql.Date;
import java.util.List;

@Mapper
public interface AppMapper {
    @Select("select * from `apply` where id = #{id}")
    Apply selectById(Integer id);

    @Insert("INSERT INTO `apply` ( old_role, new_role, apply_date, status,reason) " +
            "VALUES (#{name}, #{title}, #{content}, #{time},#{status})")
    void insertuser(Apply user);

    @Delete("delete from `apply` where id=#{id}")
    void delectuser(Integer id);

    @Update("update `apply` set old_role = #{old_role},new_role = #{new_role},apply_date = #{apply_date},status = #{status},reason = #{reason} where id=#{id}")
    void updateuser(Apply user);

    @Select("SELECT * " +
            "FROM `apply` " +
            "ORDER BY id DESC " +
            "LIMIT #{skipNum}, #{pageSize}")
    List<Apply> selectBypage(
            @Param("skipNum") Integer skipNum,
            @Param("pageSize") Integer pageSize
    );

    @Select("select count(id) from `apply` ")
    int selectCountByPage();

    @PutMapping("update `apply` set  status = #{status} where id=#{id}")
    void updatestatus(Apply user);

}
